<?php

namespace app\api\controller;


use app\common\model\MeetingLog;
use think\Request;

/**
 * @title 会议
 */
class Meeting extends \app\common\controller\Api
{
    protected $noNeedLogin = [''];
    protected $noNeedRight = '*';


    /**
     * @title 添加会议记录
     * @description
     * @param name:meeting_title type:string require:1  other: default: desc:会议名称
     * @param name:emcee_user_id type:string require:1  other: default: desc:主持人
     * @param name:meeting_time type:string require:1  other: default: desc:会议日期
     * @param name:address type:string require:1  other: default: desc:会议地点
     * @param name:attendee type:string require:1  other: default: desc:出席人员
     * @param name:report_user_id type:string require:1  other: default: desc:汇报人
     * @param name:charge_user_id type:string require:1  other: default: desc:负责人
     * @param name:meeting_content type:string require:1  other: default: desc:会议内容记录
     * @param name:meeting_images type:string require:1  other: default: desc:会议图片
     * @return res:结果
     * @author
     * @url /api/meeting/add
     * @method POST
     */
    public function add(Request $request){
        $res = MeetingLog::create(array_merge(input(), ["user_id"=>$this->auth->id]));
        $this->success("", $res);
    }

    /**
     * @title 获取会议列表
     * @description
     * @param name:id type:string require:1  other: default: desc:id
     * @param name:date type:string require:1  other: default: desc:时间检索(YYYY-MM-DD)
     * @return res:结果
     * @author
     * @url /api/meeting/list
     * @method POST
     */
    public function list(Request $request){
        $date = $request->param("date");
        $this->success("", MeetingLog::where(function ($query) use ($date) {
            if (!empty($date)) {
                $query->whereRaw("DATE(createtime) = ". $date);
            }
        })->order("createtime","desc")->paginate(20));
    }

    /**
     * @title 获取会议详情
     * @description
     * @param name:id type:string require:1  other: default: desc:id
     * @return res:结果
     * @author
     * @url /api/meeting/desc
     * @method POST
     */
    public function desc(Request $request){
        $this->success("", MeetingLog::get(input("id",["user","EmceeUser","reportUser","chargeUser"])));
    }
}


































